Current Location: Home> Function Categories> date_sunset

date_sunset

Returns the sunset time for a given date and location
Name:date_sunset
Category:Date and time
Programming Language:php
One-line Description:Returns the sunset time for the specified date and location.

Definition and usage

date_sunset() function returns the sunset time of the specified date and place.

Tip: See the date_sunrise() function to return the sunrise time of the specified date and place.

Example

Return to the sunset time in Lisbon, Portugal today:

 <?php
// Shanghai, China:
// Dimension: North latitude 31.22, longitude: West latitude 121.47
// Zen ~= 90, offset: +8 GMT

echo ( "Shanghai, China: Date: " . date ( "DM d Y" ) ) ;
echo ( "<br>Sunrise time:" ) ;
echo ( date_sunrise ( time ( ) , SUNFUNCS_RET_STRING , 31.22 , 121.47 , 90 , 8 ) ) ;
?>

Try it yourself

grammar

 date_sunset ( timestamp , format , latitude , longitude , zenith , gmtoffset ) ;
parameter describe
timestamp Required. Specifies the date and time stamp to calculate the sunset time.
format

Optional. Specifies how to return the result:

  • SUNFUNCS_RET_STRING (return the result as a string, for example 16:46) (default)
  • SUNFUNCS_RET_DOUBLE (return the result in a floating point number, for example 16.78243132)
  • SUNFUNCS_RET_TIMESTAMP (returns the result as an integer (timestamp), for example 1095034606)
latitude Optional. The latitude of the specified location. The default is North latitude. To specify a South Latitude, pass a negative value.
longitude Optional. The longitude of the specified location. By default, it refers to Eastern Longitude. If you need to specify the Western Bible, please pass a negative value.
zenith Optional. The default is date.sunset_zenith.
gmtoffset Optional. Specifies the difference between GMT and local time, in hours.
Similar Functions